package edu.asu.cse360.client.context;

import java.util.Locale;

import org.springframework.context.ApplicationContext;
import org.springframework.context.MessageSource;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import edu.asu.cse360.client.i18n.MessageResolver;
import edu.asu.cse360.model.CustomerSession;
import edu.asu.cse360.model.Employee;
import edu.asu.cse360.model.Restaurant;
import edu.asu.cse360.model.Table;
/**
 * Contains the information to run the program. It sets what mode the program has to run in either employee or customer
 * @author nadimhoque
 */
public class RestaurantContext{
	private static ApplicationContext appContext;
	private static boolean isCustomerMode;
	private static MessageResolver messageResolver;
        private static Employee loggedInUser;
        private static Restaurant restaurant;
        private static Table table;
        private static CustomerSession customerSession;
        
	static{
            appContext = new ClassPathXmlApplicationContext("/spring-context/client-context.xml");
	}

	
	public static void refresh(){
	}	
	
	public RestaurantContext(){
	}

	public static MessageResolver getMessageResolver(){
            if(messageResolver == null){
                MessageSource messageSource = appContext.getBean(MessageSource.class);
                messageResolver = new MessageResolver(messageSource, Locale.US);
            }
            return messageResolver;
	}

        public static Employee getLoggedInUser(){
            return loggedInUser;
        }

        public static boolean isCustomerMode(){
            return isCustomerMode;
        }

        public static void setCustomerMode(boolean pIsCustomerMode){
            isCustomerMode = pIsCustomerMode;
        }

        public static Restaurant getRestaurant(){
            return restaurant;
        }

        public static Table getTable(){
            return table;
        }
        public static void setRestaurant(Restaurant pRestaurant){
            restaurant = pRestaurant;
        }
        public static void setTable(Table pTable){
            table = pTable;
        }
        public static void setloggedInUser(Employee pLoggedInUser){
            loggedInUser = pLoggedInUser;
        }

        public static CustomerSession getSession(){
            return customerSession;
        }

        public static void setSession(CustomerSession pCustomerSession){
            customerSession = pCustomerSession;
        }

}
